#include "MarketPrices.h"


MarketPrices::~MarketPrices()
{
}


MarketPrices::MarketPrices(const MarketPrices& m)
{
	goldPrice = m.getGold();
	silverPrice = m.getSilver();
	copperPrice = m.getCopper();
}


MarketPrices& MarketPrices::operator=(const MarketPrices& m)
{
	if (this != &m)
	{
		this->copperPrice = m.getCopper();
		this->silverPrice = m.getSilver();
		this->goldPrice = m.getGold();
	}
	return *this;
}


//acccessors
void MarketPrices::getCompletePrice(int& c, int& s, int& g)
{
	c = copperPrice;
	s = silverPrice;
	g = goldPrice;
}


//mutators
void MarketPrices::setCopper(int c)
{
	copperPrice = c;
	updateCoinNumber();
}


void MarketPrices::setSilver(int s)
{
	silverPrice = s;
	updateCoinNumber();
}


void MarketPrices::setGold(int g)
{
	goldPrice = g;
}


void MarketPrices::setPrice(int c, int s, int g)
{
	copperPrice = c;
	silverPrice = s;
	goldPrice = g;
	updateCoinNumber();
}


//private mutators
void MarketPrices::updateCoinNumber()
{
	int mod, div;
	if (copperPrice >= 100)
	{
		mod = copperPrice % 100;
		div = copperPrice / 100;
		copperPrice = mod;
		silverPrice += div;
	}
	if (silverPrice >= 100)
	{
		mod = silverPrice % 100;
		div = silverPrice / 100;
		silverPrice = mod;
		goldPrice += div;
	}
}